package com.kbt.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.kbt.adapter.GoodForJfdhAdapter;
import com.kbt.base.BaseApplication;
import com.kbt.model.data.GoodForJFInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhgk
 * @package: com.kbt.activity
 * @TODO: 用积分兑换的商品的列表
 * @data: 2015/8/17 17:20
 * @version: V1.0
 */
public class GoodListForJfActivity extends Activity {

    //积分商品竞换列表
    private ListView jfGoodListView;
    private List<GoodForJFInfo> goodJfList;
    private GoodForJfdhAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.good_jf_duihuan);
        this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_return_btn);

        //设置返回按钮事件,关闭当前Activity，返回数据
        ImageView returnImg = (ImageView) findViewById(R.id.return_btn);
        returnImg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //不创建地址
                setResult(RESULT_CANCELED, null);
                BaseApplication.getInstance().removeActivity(GoodListForJfActivity.this);
                finish();
            }
        });

        TextView appTitleView = (TextView) findViewById(R.id.center_title);
        appTitleView.setText("兑换记录");
    }

    @Override
    protected void onStart() {
        super.onStart();
        BaseApplication.getInstance().addActivity(GoodListForJfActivity.this);
        //初始化数据
        initListViewData();
        //初始化视图
        initListView();

    }

    /********
     * 初始化视图
     */
    private void initListView() {
        jfGoodListView = (ListView) findViewById(R.id.goodForJFList);
        adapter = new GoodForJfdhAdapter(this, goodJfList);
        jfGoodListView.setAdapter(adapter);
    }

    private void initListViewData() {
        goodJfList = new ArrayList<GoodForJFInfo>();
        GoodForJFInfo jfInfo;
        for (int i = 0; i < 30; i++) {
            jfInfo = new GoodForJFInfo();
            jfInfo.setGoodCount("3");
            jfInfo.setGoodPrice(123.0f);
            jfInfo.setGoodTotalFee(369.00f);
            jfInfo.setGoodTitle("商品" + i);
            goodJfList.add(jfInfo);
        }
    }
}
